import dayjs from "dayjs";

export const formatDate = (
	value: string | number | Date,
	template = "YYYY-MM-DD HH:mm:ss",
) => {
	if (!value) return null;
	return dayjs(value).format(template);
};

export const formatPrice = (
	value: number | null,
	precision = 2,
	currency = "￥",
) => {
	if (value === null || value === undefined) return null;

	return `${currency}${value.toFixed(precision)}`;
};
